package com.grape.transaction.lcn.service;

import com.codingapi.txlcn.tc.annotation.TxTransaction;
import com.grape.transaction.lcn.fegin.ProducerFegin;
import com.grape.transaction.lcn.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.client.RestTemplate;

@Service
public class ConsumerService {
    @Autowired
    UserMapper userMapper;
    @Autowired
    RestTemplate restTemplate;
    @Autowired
    ProducerFegin producerFegin;


    @TxTransaction
    @Transactional
    public void addUser(String i) {
        userMapper.insert("myx",26);
        //调用没有作用
//        HttpUtil.get("http://127.0.0.1:6667/user?i="+i);
        restTemplate.getForObject("http://127.0.0.1:6668/user?i="+i,void.class);
        int j=5/Integer.parseInt(i);
//        producerFegin.addUser(i);
    }
}
